package show.me.the.money.accredit;

import java.util.ArrayList;
import java.util.List;


import org.dom4j.Element;

import show.me.the.money.accredit.condition.Condition;
import show.me.the.money.accredit.condition.ConditionFactory;
import show.me.the.money.accredit.result.AuthorizeResult;
import show.me.the.money.accredit.result.ConditionResult;


public class AccreditStoreItem {
	List<Condition> cds = new ArrayList<Condition>();
	private String acValue = "0000";
	
	@SuppressWarnings("unchecked")
	public AccreditStoreItem(Element define){
				
		if(define == null){
			return;
		}
		define.attributeValue("id");
		acValue = define.attributeValue("acValue","1111");
		List<Element> els = define.elements("condition");
		for(Element el:els){
			Condition cd = ConditionFactory.createCondition(el);
			cds.add(cd);
		}
	}
	
	public AuthorizeResult getResult(){
		ConditionResult r = new ConditionResult();
		r.setAuthorizeValue(acValue);
		r.setAllConditions(cds);
		return r;
	}
}
